package com.mk3.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mk3.mapper.UserMapper;
import com.mk3.model.User;
import org.springframework.stereotype.Service;

/**
 * @Author: peisong.chen
 * @Date: 2019/12/27 10:38
 * @Description:
 */
@Service
public class UserService extends ServiceImpl<UserMapper, User> {

    public int insertUser(User user) {
        return baseMapper.insert(user);
    }

    public int updateUser(User user) {
        return baseMapper.updateById(user);
    }

    public int deleteUser(User user) {
        return baseMapper.deleteById(user.getId());
    }

    /**
     * 查：普通查
     *
     * @param userName
     * @return
     */
    public User findUserByName(String userName) {
        return baseMapper.getUserByName(userName);
    }

    /**
     * 分页查
     *
     * @param page
     * @param name
     * @return
     */
    public IPage getUserPage(Page page, String name) {
        return baseMapper.getUsersPage(page, name);
    }

}
